home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / E / inc_source / xpk.e next >
Text File  |  1998-11-09  |  11KB  |  309 lines

  1. /*
  2. ** File is made of V2.5 Includes. It is no longer up-to-date!
  3. **
  4. ** Converted from C include file to E module by
  5. ** Torgil Svenssom (snorq@lysator.liu.se) in 1995
  6. **
  7. */
  8.  
  9.  
  10. OPT MODULE
  11. OPT PREPROCESS
  12. OPT EXPORT
  13.  
  14.  
  15. -> there are two defines left. this and one at the bottom
  16.  
  17. #define XPKNAME 'xpkmaster.library'
  18.  
  19. /*****************************************************************************
  20.  *
  21.  *
  22.  *      The packing/unpacking tags
  23.  *
  24.  */
  25.  
  26. CONST XPK_TagBase = TAG_USER + "X"*256 + "P"
  27. CONST XTAG        = XPK_TagBase
  28.  
  29. -> Caller must supply ONE of these to tell Xpk#?ackFile where to get data from
  30.  
  31. CONST XPK_InName = XTAG+$01,  -> Process an entire named file
  32.       XPK_InFH   = XTAG+$02   -> File handle - start from current position
  33.  
  34. -> If packing partial file, must also supply InLen
  35.  
  36. CONST XPK_InBuf  = XTAG+$03,  -> Single unblocked memory buffer, supply InLen
  37.       XPK_InHook = XTAG+$04   -> Call custom Hook to read data
  38.  
  39. -> If packing, must also supply InLen
  40. -> If unpacking, InLen required only for PPDecrunch
  41.  
  42. -> Caller must supply ONE of these to tell Xpk#?ackFile where to send data to
  43. CONST XPK_OutName   = XTAG+$10, -> Write (or overwrite) this data file
  44.       XPK_OutFH     = XTAG+$11, -> File handle - write from current pos on
  45.       XPK_OutBuf    = XTAG+$12,    -> Unblocked buf - must also supply OutBufLen
  46.       XPK_GetOutBuf = XTAG+$13,    -> Master alloc. OutBuf tag data pts to buf ptr
  47.       XPK_OutHook   = XTAG+$14  -> Callback Hook to get output buffers
  48.  
  49. -> Other tags for Pack/Unpack
  50. CONST XPK_InLen        = XTAG+$20,  -> Length of data in input buffer
  51.       XPK_OutBufLen    = XTAG+$21,  -> Length of output buffer
  52.       XPK_GetOutLen    = XTAG+$22,  -> tag data pts to long to receive OutLen
  53.       XPK_GetOutBufLen = XTAG+$23,  -> tag data pts to long to rec. OutBufLen
  54.       XPK_Password     = XTAG+$24,  -> Password for de/encoding
  55.       XPK_GetError     = XTAG+$25,  -> ti_Data points to buf for error message
  56.       XPK_OutMemType   = XTAG+$26,  -> Memory type for output buffer
  57.       XPK_PassThru     = XTAG+$27,  -> Bool: Pass through unrec.formats on unpck
  58.       XPK_StepDown     = XTAG+$28,  -> Bool: Step down pack method if necessary
  59.       XPK_ChunkHook    = XTAG+$29,  -> Call this Hook between chunks
  60.       XPK_PackMethod   = XTAG+$2a,  -> Do a FindMethod before packing
  61.       XPK_ChunkSize    = XTAG+$2b,  -> Chunk size to try to pack with
  62.       XPK_PackMode     = XTAG+$2c,  -> Packing mode for sublib to use
  63.       XPK_NoClobber    = XTAG+$2d,  -> Don't overwrite existing files
  64.       XPK_Ignore       = XTAG+$2e,  -> Skip this tag
  65.       XPK_TaskPri      = XTAG+$2f,  -> Change priority for (un)packing
  66.       XPK_FileName     = XTAG+$30,  -> File name for progress report
  67.       XPK_ShortError   = XTAG+$31,  -> Output short error messages
  68.       XPK_PackersQuery = XTAG+$32,  -> Query available packers
  69.       XPK_PackerQuery  = XTAG+$33,  -> Query properties of a packer
  70.       XPK_ModeQuery    = XTAG+$34,  -> Query properties of packmode
  71.       XPK_LossyOK      = XTAG+$35   -> Lossy packing permitted? def.=no
  72.  
  73.  
  74. CONST XPK_FindMethod = XPK_PackMethod, -> Compatibility
  75.       XPK_MARGIN     = 256             -> Safety margin for output buffer
  76.  
  77.  
  78.  
  79.  
  80. /*****************************************************************************
  81.  *
  82.  *
  83.  *     The hook function interface
  84.  *
  85.  */
  86.  
  87. -> Message passed to InHook and OutHook as the ParamPacket
  88. OBJECT xpkIOMsg
  89.     type      :LONG   -> (unsigned) Read/Write/Alloc/Free/Abort
  90.     ptr       :LONG   -> (APTR) The mem area to read from/write to
  91.     size      :LONG   -> The size of the read/write
  92.     ioError   :LONG   -> The IoErr() that occurred
  93.     reserved  :LONG   -> Reserved for future use
  94.     private1  :LONG   -> Hook specific, will be set to 0 by
  95.     private2  :LONG   -> master library before first use
  96.     private3  :LONG
  97.     private4  :LONG
  98. ENDOBJECT
  99.  
  100. -> The values for xpkIoMsg.type
  101. CONST XIO_READ    = 1,
  102.       XIO_WRITE   = 2,
  103.       XIO_FREE    = 3,
  104.       XIO_ABORT   = 4,
  105.       XIO_GETBUF  = 5,
  106.       XIO_SEEK    = 6,
  107.       XIO_TOTSIZE = 7
  108.  
  109.  
  110.  
  111.  
  112.  
  113. /*****************************************************************************
  114.  *
  115.  *
  116.  *      The progress report interface
  117.  *
  118.  */
  119.  
  120. -> Passed to ChunkHook as the ParamPacket
  121. OBJECT xpkProgress
  122.   type          :LONG         -> Type of report: start/cont/end/abort
  123.   packerName    :PTR TO CHAR    -> Brief name of packer being used
  124.   packerLongName:PTR TO CHAR  -> Descriptive name of packer being used
  125.   activity      :PTR TO CHAR  -> Packing/unpacking message
  126.   fileName      :PTR TO CHAR  -> Name of file being processed, if available
  127.  
  128.   ccur          :LONG   -> Amount of packed data already processed
  129.   ucur          :LONG   -> Amount of unpacked data already processed
  130.   ulen          :LONG   -> Amount of unpacked data in file
  131.   cf            :LONG   -> Compression factor so far
  132.   done          :LONG   -> Percentage done already
  133.   speed         :LONG   -> Bytes per second, from beginning of stream
  134.   reserved[8]   :ARRAY  -> For future use
  135. ENDOBJECT
  136.  
  137. CONST XPKPROG_START = 1,
  138.       XPKPROG_MID   = 2,
  139.       XPKPROG_END   = 3
  140.  
  141.  
  142.  
  143.  
  144.  
  145. /*****************************************************************************
  146.  *
  147.  *
  148.  *       The file info block
  149.  *
  150.  */
  151.  
  152. OBJECT xpkFib
  153.   type  :LONG   -> Unpacked, packed, archive?
  154.   ulen  :LONG   -> Uncompressed length
  155.   dlen  :LONG   -> Compressed length
  156.   nlen  :LONG   -> Next chunk len
  157.   ucur  :LONG   -> Uncompressed bytes so far
  158.   ccur  :LONG        -> Compressed bytes so far
  159.   id    :LONG        -> 4 letter ID of packer
  160.  
  161.   packer[6]   :ARRAY  -> (unsigned) 4 letter name of packer
  162.   subVersion  :INT    -> Required sublib version
  163.   masVersion  :INT    -> Required masterlib version
  164.   flags       :INT    -> Password?
  165.   head[16]    :ARRAY  -> (unsigned) First 16 bytes of orig. file
  166.   ratio       :LONG   -> Compression ratio
  167.  
  168.   reserved[8] :ARRAY OF LONG    -> For future use
  169. ENDOBJECT
  170.  
  171. CONST XPKTYPE_UNPACKED  = 0,  -> Not packed
  172.       XPKTYPE_PACKED    = 1,  -> Packed file
  173.       XPKTYPE_ARCHIVE   = 2   -> Archive
  174.  
  175. CONST XPKFLAGS_PASSWORD = 1,  -> Password needed
  176.       XPKFLAGS_NOSEEK   = 2,  -> Chunks are dependent
  177.       XPKFLAGS_NONSTD   = 4   -> Nonstandard file format
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184. /*****************************************************************************
  185.  *
  186.  *
  187.  *       The error messages
  188.  *
  189.  */
  190.  
  191. CONST XPKERR_OK          =   0,
  192.       XPKERR_NOFUNC      =  -1, -> This function not implemented
  193.       XPKERR_NOFILES     =  -2, -> No files allowed for this function
  194.       XPKERR_IOERRIN     =  -3, -> Input error happened, look at Result2
  195.       XPKERR_IOERROUT    =  -4, -> Output error happened,look at Result2
  196.       XPKERR_CHECKSUM    =  -5, -> Check sum test failed
  197.       XPKERR_VERSION     =  -6, -> Packed file's version newer than lib
  198.       XPKERR_NOMEM       =  -7, -> Out of memory
  199.       XPKERR_LIBINUSE    =  -8, -> For not-reentrant libraries
  200.       XPKERR_WRONGFORM   =  -9, -> Was not packed with this library
  201.       XPKERR_SMALLBUF    = -10, -> Output buffer too small
  202.       XPKERR_LARGEBUF    = -11, -> Input buffer too large
  203.       XPKERR_WRONGMODE   = -12, -> This packing mode not supported
  204.       XPKERR_NEEDPASSWD  = -13, -> Password needed for decoding
  205.       XPKERR_CORRUPTPKD  = -14, -> Packed file is corrupt
  206.       XPKERR_MISSINGLIB  = -15, -> Required library is missing
  207.       XPKERR_BADPARAMS   = -16, -> Caller's TagList was screwed up
  208.       XPKERR_EXPANSION   = -17, -> Would have caused data expansion
  209.       XPKERR_NOMETHOD    = -18, -> Can't find requested method
  210.       XPKERR_ABORTED     = -19, -> Operation aborted by user
  211.       XPKERR_TRUNCATED   = -20, -> Input file is truncated
  212.       XPKERR_WRONGCPU    = -21, -> Better CPU required for this library
  213.       XPKERR_PACKED      = -22, -> Data are already XPacked
  214.       XPKERR_NOTPACKED   = -23, -> Data not packed
  215.       XPKERR_FILEEXISTS  = -24, -> File already exists
  216.       XPKERR_OLDMASTLIB  = -25, -> Master library too old
  217.       XPKERR_OLDSUBLIB   = -26, -> Sub library too old
  218.       XPKERR_NOCRYPT     = -27, -> Cannot encrypt
  219.       XPKERR_NOINFO      = -28, -> Can't get info on that packer
  220.       XPKERR_LOSSY       = -29, -> This compression method is lossy
  221.       XPKERR_NOHARDWARE  = -30, -> Compression hardware required
  222.       XPKERR_BADHARDWARE = -31, -> Compression hardware failed
  223.       XPKERR_WRONGPW     = -32  -> Password was wrong
  224.  
  225.  
  226. CONST XPKERRMSGSIZE    = 80    ->  Maximum size of an error message
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233. /*****************************************************************************
  234.  *
  235.  *
  236.  *     The XpkQuery() call
  237.  *
  238.  */
  239.  
  240. OBJECT xpkPackerInfo
  241.   name[24]        :ARRAY  -> Brief name of the packer
  242.   longName[32]    :ARRAY  -> Full name of the packer
  243.   description[80] :ARRAY  -> One line description of packer
  244.  
  245.   flags     :LONG   -> Defined below
  246.   maxChunk  :LONG   -> Max input chunk size for packing
  247.   defChunk  :LONG   -> Default packing chunk size
  248.   defMode   :INT    -> (unsigned) Default mode on 0..100 scale
  249. ENDOBJECT
  250.  
  251. -> Defines for Flags
  252. CONST XPKIF_PK_CHUNK    = $00000001, -> Library supplies chunk packing
  253.       XPKIF_PK_STREAM   = $00000002, -> Library supplies stream packing
  254.       XPKIF_PK_ARCHIVE  = $00000004, -> Library supplies archive packing
  255.       XPKIF_UP_CHUNK    = $00000008, -> Library supplies chunk unpacking
  256.       XPKIF_UP_STREAM   = $00000010, -> Library supplies stream unpacking
  257.       XPKIF_UP_ARCHIVE  = $00000020, -> Library supplies archive unpacking
  258.       XPKIF_HOOKIO      = $00000080, -> Uses full Hook I/O
  259.       XPKIF_CHECKING    = $00000400, -> Does its own data checking
  260.       XPKIF_PREREADHDR  = $00000800, -> Unpacker pre-reads the next chunkhdr
  261.       XPKIF_ENCRYPTION  = $00002000, -> Sub library supports encryption
  262.       XPKIF_NEEDPASSWD  = $00004000, -> Sub library requires encryption
  263.       XPKIF_MODES       = $00008000, -> Sub library has different modes
  264.       XPKIF_LOSSY       = $00010000  -> Sub library does lossy compression
  265.  
  266.  
  267. OBJECT xpkMode
  268.   next  :PTR TO xpkMode -> Chain to next descriptor for ModeDesc list*/
  269.  
  270.   upto        :LONG     -> (unsigned) Maximum efficiency handled by this mode
  271.   flags       :LONG     -> (unsigned) Defined below
  272.   packMemory  :LONG     -> (unsigned) Extra memory required during packing
  273.   unpackMemory:LONG     -> (unsigned) Extra memory during unpacking
  274.   packSpeed   :LONG     -> (unsigned) Approx packing speed in K per second
  275.   unpackSpeed :LONG     -> (unsigned) Approx unpacking speed in K per second
  276.   ratio       :INT      -> (unsigned) CF in 0.1% for AmigaVision executable
  277.   chunkSize   :INT      -> (unsigned) Desired chunk size in K (!!) for this mode
  278.  
  279.   description[10]:ARRAY -> 7 character mode description
  280. ENDOBJECT
  281.  
  282. -> Defines for XpkMode.Flags
  283. CONST XPKMF_A3000SPEED = $00000001, -> Timings on A3000/25
  284.       XPKMF_PK_NOCPU   = $00000002, -> Packing not heavily CPU dependent
  285.       XPKMF_UP_NOCPU   = $00000004  -> Unpacking... (i.e. hardware modes)
  286.  
  287. CONST MAXPACKERS = 100
  288. CONST XPK_PACKER_ARRAY_SIZE = MAXPACKERS * 6
  289.  
  290. OBJECT xpkPackerList
  291.   numPackers                    :LONG   -> (unsigned)
  292.   packer[XPK_PACKER_ARRAY_SIZE] :ARRAY  -> MAXPACKERS items. 6 bytes each
  293. ENDOBJECT
  294.  
  295.  
  296.  
  297.  
  298. /*****************************************************************************
  299.  *
  300.  *
  301.  *     The XpkOpen() type calls
  302.  *
  303.  */
  304.  
  305. CONST XPKLEN_ONECHUNK = $7fffffff
  306.  
  307. #define xpkFH xpkFib
  308.  
  309.